﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DQYT.HTDZ.Model;
using DQYT.HTDZ.BLL;
using System.Data;
using DQYT.HTDZ.Common;
using System.Data.OracleClient;
using System.IO;
using Maticsoft.DBUtility;

namespace SkWeb.Handlers
{
    public partial class SkgysjbHandler : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string op = Request.QueryString["op"];
            string resultJson = string.Empty;
            try
            {
                switch (op)
                {
                    case "updateskgysjb":
                        SkgysjbModel model = new SkgysjbModel();
                        string id = Request.Form["id"];
                        if (string.IsNullOrWhiteSpace(id))
                        {
                            resultJson = "{\"success\":false, \"msg\":\"ID参数不可为空 \"}";
                        }
                        else
                        {

                            model.ID = int.Parse(id);
                            model.JB = Request.Form["jb"];
                            model.YCZBSD = string.IsNullOrWhiteSpace(Request.Form["qcyzsd"]) ? 0 : double.Parse(Request.Form["qcyzsd"]);
                            model.SKJD1 = string.IsNullOrWhiteSpace(Request.Form["skjd1"]) ? 0 : double.Parse(Request.Form["skjd1"]);
                            model.SKJD2 = string.IsNullOrWhiteSpace(Request.Form["skjd2"]) ? 0 : double.Parse(Request.Form["skjd2"]);
                            model.YGGG = Request.Form["yggg"];
                            model.WJYMC = Request.Form["wjymc"];
                            model.WJYMD = string.IsNullOrWhiteSpace(Request.Form["wjymd"]) ? 0 : double.Parse(Request.Form["wjymd"]);
                            model.SKQX = Request.Form["skqx"];
                            model.SKDX = Request.Form["skdx"];

                            SkgysjbBLL skgysjbBLL = new SkgysjbBLL();
                            skgysjbBLL.UpdateSchemeDesignWell(model);

                            resultJson = "{\"success\":true}";
                        }

                        break;
                    case "getygcs":
                        YGCSBLL ygcsbll = new YGCSBLL();
                        DataTable ygcsTable = ygcsbll.QueryBySkgysjbId(int.Parse(Request.Form["id"]));
                        resultJson = JsonHelper.ToJson(ygcsTable);
                        break;

                    case "updatesygcs":
                        YGCSBLL ygcs = new YGCSBLL();
                        YGCSModel ygcsModel = new YGCSModel();
                        ygcsModel.ID = int.Parse(Request["id"]);
                        ygcsModel.PTCD = string.IsNullOrWhiteSpace(Request["ptcd"]) ? 0 : int.Parse(Request["ptcd"]);
                        ygcsModel.YGGS = string.IsNullOrWhiteSpace(Request["yggs"]) ? 0 : int.Parse(Request["yggs"]);
                        ygcsModel.DWDJ = string.IsNullOrWhiteSpace(Request["dwdj"]) ? 0 : int.Parse(Request["dwdj"]);
                        ygcs.UpdateById(ygcsModel);
                        resultJson = "{\"success\":true}";
                        break;
                 

                }
            }
            catch (Exception ex)
            {
                resultJson = "{\"success\":false, \"msg\":\"系统出现异常，请联系管理员！ \"}";
            }
            
            Response.ContentType = "text/json";
            Response.Write(resultJson);
        }




      




    }
}